import { IPage } from 'api';
import { request } from 'utils/request';

export interface IGoodsInfo {
  id: string;
  /**
   * 名字
   */
  name: string;

  /**
   * 商品类别,字典key
   */
  typeKey: string;

  /**
   * 价格
   */
  price: number;

  /**
   * 描述
   */
  description: string;

  /**
   * 库存
   */
  account: number;

  /**
   * 图片url
   */
  picture: string;
}

export const getGoodsList = (data: any) =>
  request<IPage<IGoodsInfo>>({
    url: '/goods/list',
    method: 'post',
    data,
  });

export const deleteGoods = (id: number) =>
  request<boolean>({
    url: '/goods/delete',
    method: 'post',
    data: { id },
  });

export const updateGoods = (data: any) =>
  request<boolean>({
    url: '/goods/update',
    method: 'post',
    data,
  });

export const addGoods = (data: any) =>
  request<boolean>({
    url: '/goods/add',
    method: 'post',
    data,
  });
